layui.use(['laydate','form','table','laytpl','layer','gcate'], function(){
	var laydate = layui.laydate;
	var form = layui.form;
	var table = layui.table;
	var laytpl = layui.laytpl;
	var layer = layui.layer;
	var gcate = layui.gcate;

	/*@产品分类*/
	gcate.form.g_cate('select', '/staff/goods/sun_cate');
	/*@计算支出总额*/
	num_price = function(obj,field,total){
		let v = $(obj).val()
		let br = $('input[name="'+field+'"]').val()
		let money = (Number(v*100) * Number(br*100))/10000;
		$('input[name="'+total+'"]').val(money)
	}
	/*@验证*/
	form.verify({
		money: function(value){
			let num = $('input[name="number"]').val()
			let price = $('input[name="buying_price"]').val()
			if(Number(value) != Number(num) * Number(price)){
				return '支出总额不等于采购数量*进货单价';
			}
		},
		ty: function($value){
			if($('input[name="ty"]:checked').length == 0){
				return '请选择退款类型';
			}
		}
	})
	// /*@查询*/
	form.on('submit(query_btn)',function(data){
		console.log(data)
		$.post('', data.field, function(msg){
			if(msg.code !== 1){
				layer.msg(msg.msg, {icon: 5})
			}else{
				parent.layui.tableObj.reload()
				layer.msg(msg.msg, {icon: 6}, function(){
					xadmin.close()
				})
				
			}
		})
	})
	
});